import htmlparser
from configurator import config_parser
from configurator import *
from BlogParsers import *

__author__="user"
__date__ ="$2008-11-21 16:30:00$"





if __name__ == "__main__":
    print "start"


class Crawler:


    def __init__(self, configuration_file):
        self.configuration_file = configuration_file

    def info(self, obj):
        print "Info"

    def demonstration(self, obj):
	#            blog = obj.get_blog_by_address()
            print "TRESC BLOGA:"
         #   print blog
            print "\n\n\n\n\n\n"

            print "INNE BLOGI:"
            inne =  obj.get_other_blogs_address()
            print "wyszstkich: " + str(len(inne))
            print "przyklakowe"
            return inne[:5]
            print "\n\n"
            print "LISTA KOMENTARZT"
            #lista = obj.get_comment_list()
	    
            print "przyklad"
          #  print lista[0][:5]
            print "\n\n"
            print "KOMENTARZ"
            print "przyklad"
            #return obj.get_one_comment(lista[0][2])

    def demo(self):
        for parser, type, address, function in config_parser(self.configuration_file):

            cmd = "obj = " + str(parser)+"('"+str(address)+"')"
            exec(cmd)
            obj.start()
            cmd = "self." + function + "(" + "obj" + ")"
            exec(cmd)
            return self.demonstration(obj)

#    for x in config_parser("konfiguracja.xml"):
 #       xx= x[2]
  #      o =     Onet(xx)
   #     o.start()
        #b=  o.get_blog_by_address()
        #print len(o.get_other_blogs_address())
        #for t in o.get_other_blogs_address():
        #    print t
    #    a =  o.get_comment_list()
     #   print a[0][2]
      #  print o.get_one_comment(a[0][2])

def start_demo():
    crawler = Crawler(r"C:\django\System\io-bloganalisys\bloganalisys\crawler\konfiguracja.xml")
    crawler.demo()

#start_demo()


